<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>controlP5 : : Textfield</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
document.getElementsByTagName('html')[0].className = 'isjs';

function toggle(dt) 
{ 
  var display, dd=dt; 
  /* get dd */ 
  do{ dd = dd.nextSibling } while(dd.tagName!='DD'); 
  toOpen =!dd.style.display; 
  dd.style.display = toOpen? 'block':'' 
  dt.getElementsByTagName('span')[0].innerHTML 
    = toOpen? '-':'+' ; 
} 
</script>
</head>
<body>
<div id="container">
		<div id="header">
		<a href="./index.htm"><img src="./docuImages/title.jpg" /></a>
		</div>
	<div class="content">
		<h1>Textfield</h1>
		<dl><dt class="key">description</dt><dd class="value">description for singleline textfield. create a texfield with<br />
 <br />
 controlP5.addTextfield(theName,theX,theY,theWidth,theHeight);
 
 the Textfield implementation for ControlP5 tries its best to imitate the
 usage and behavior of a terminal, the command line.</dd></dl>
			
			<div class="toggleList example">
				<dl><dt onclick="toggle(this)"><span>+</span>Example</dt>
					<dd><pre>import controlP5.*;
ControlP5 controlP5;

// textfield example by andreas schlegel, 11.02.2009
// for a more advanced example see textfieldAdvanced which 
// demonstrates how to use keepFocus, setText, getText, getTextList,
// clear, setAutoClear, isAutoClear or submit.

String textValue = "";
Textfield myTextfield;

void setup() {
  size(400,400);
  frameRate(25);
  controlP5 = new ControlP5(this);
  myTextfield = controlP5.addTextfield("texting",100,160,200,20);
  myTextfield.setFocus(true);
  controlP5.addTextfield("textValue",100,200,200,20);
}

void draw() {
  background(0);
}


void controlEvent(ControlEvent theEvent) {
  println("controlEvent: accessing a string from controller '"+theEvent.controller().name()+"': "+theEvent.controller().stringValue());
}


public void texting(String theText) {
  // receiving text from controller texting
  println("a textfield event for controller 'texting': "+theText);
}

</pre></dd>
				</dl>
			</div>
			
			
			
			<dl><dt class="key">constructors</dt><dd class="value"><pre></pre></dd></dl>
			
			
			
			
			
			
			
			<!-- METHODS:BEGIN -->
			
       <dl class="noborder"><dt>Methods</dt></dl>
       <dl><dt class="key"><a href="textfield_method_clear.htm">clear ( )</a></dt><dd class="value">clear the current content of the textfield.</dd></dl>
<dl><dt class="key"><a href="textfield_method_gettext.htm">getText ( )</a></dt><dd class="value">get the current text of the textfield.</dd></dl>
<dl><dt class="key"><a href="textfield_method_gettextlist.htm">getTextList ( )</a></dt><dd class="value">returns a string array that lists all text lines that have been confirmed
 with a return.</dd></dl>
<dl><dt class="key"><a href="textfield_method_isautoclear.htm">isAutoClear ( )</a></dt><dd class="value">returns the current state of the autoClear flag.</dd></dl>
<dl><dt class="key"><a href="textfield_method_isfocus.htm">isFocus ( )</a></dt><dd class="value">check if the textfield is active and in focus.</dd></dl>
<dl><dt class="key"><a href="textfield_method_keepfocus.htm">keepFocus ( )</a></dt><dd class="value">use true as parameter to force the textfield to stay in focus. to go back
 to normal focus behavior, use false.</dd></dl>
<dl><dt class="key"><a href="textfield_method_setautoclear.htm">setAutoClear ( )</a></dt><dd class="value">use setAutoClear(false) to not clear the content of the textfield after
 confirming with return.</dd></dl>
<dl><dt class="key"><a href="textfield_method_setfocus.htm">setFocus ( )</a></dt><dd class="value">set the textfield's focus to true or false.</dd></dl>
<dl><dt class="key"><a href="textfield_method_setpasswordmode.htm">setPasswordMode ( )</a></dt><dd class="value">set the mode of the textfield to password mode, each character is shown
 as a "*" like e.g. in online password forms.</dd></dl>
<dl><dt class="key"><a href="textfield_method_settext.htm">setText ( )</a></dt><dd class="value">setText does set the text of a textfield, but will not broadcast its
 value. use setText to force the textfield to change its text. you can
 call setText any time, nevertheless when autoClear is set to true (which
 is the default), it will NOT work when called from within controlEvent or
 within a method that has been identified by ControlP5 to forward messages
 to, when return has been pressed to confirm a textfield.<br /> use
 setAutoClear(false) to enable setText to be executed for the above case.
 use yourTextfield.isAutoClear() to check if autoClear is true or false.
 <br />
 setText replaces the current/latest content of a textfield but does NOT
 overwrite the content. when scrolling through the list of textlines (use
 key up and down), the previous content that has been replaced will be put
 back into place again - since it has not been confirmed with return.</dd></dl>
<dl><dt class="key"><a href="textfield_method_setvalue.htm">setValue ( )</a></dt><dd class="value">set the value of the textfield and will broadcast the new string value
 immediately. what is the difference between setValue and setText?
 setValue does broadcast the value that has been set, setText does not
 broadcast the value, but only updates the content of a textfield. for
 further information about how setText works, see the setText
 documentation.</dd></dl>
<dl><dt class="key"><a href="textfield_method_submit.htm">submit ( )</a></dt><dd class="value">make the controller execute a return event. submit the current content of
 the texfield.</dd></dl>

   
			<!-- METHODS:END -->
			<div class="separator">
			<dl><dt class="key">usage</dt><dd class="value">Web & Application</dd></dl>
			</div>
			<div class="separator">
			<dl><dt class="key">related</dt><dd class="value"><ul><li><a href="controller_class_controller.htm">Controller</a></li>
</ul></dd></dl>
			</div>
	</div>
	<div id="footer">
	<p>by andreas schlegel (<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">cc</a>) 2007, <a href="http://www.sojamo.de" target="_blank">sojamo</a>.</p>
	</div>
</div>
</body>
</html>


